home *** CD-ROM | disk | FTP | other *** search
- property objectList, activeObject, thisStillDown, thisRollOver, thisMouseLoc, newstilldown, newrollover, newmouseloc, sendmouseclick, thestagerect, onstage
-
- on new me
- global savedcursor
- set activeObject to 0
- set objectList to []
- set thisRollOver to 0
- set thisStillDown to 0
- set thisMouseLoc to point(-1, -1)
- set newstilldown to 0
- set newrollover to 0
- set newmouseloc to 0
- if voidp(savedcursor) then
- set savedcursor to #plain
- end if
- set thestagerect to rect(0, 0, the stageRight - the stageLeft, the stageBottom - the stageTop)
- set onstage to 0
- return me
- end
-
- on subscribe me, whichObject
- if getPos(objectList, whichObject) = 0 then
- add(objectList, whichObject)
- end if
- end
-
- on unsubscribe me, whichObject
- deleteOne(objectList, whichObject)
- end
-
- on mouseCheck me
- if sendmouseclick then
- set sendmouseclick to 0
- sendoff("mouse click")
- end if
- set theMouseLoc to point(the mouseH, the mouseV)
- set nowonstage to inside(theMouseLoc, thestagerect)
- if nowonstage <> onstage then
- set onstage to nowonstage
- if onstage then
- resetcursor(me)
- end if
- end if
- if onstage then
- areYouThere(me, theMouseLoc)
- end if
- end
-
- on areYouThere me, xLoc
- set nextstilldown to the stillDown
- set newstilldown to nextstilldown <> thisStillDown
- if newstilldown then
- if nextstilldown then
- set sendmouseclick to 1
- end if
- end if
- set thisStillDown to nextstilldown
- set newmouseloc to xLoc <> thisMouseLoc
- set thisMouseLoc to xLoc
- if activeObject = 0 then
- if not thisStillDown then
- repeat with i in objectList
- set returnThis to areYouThere(i, xLoc)
- if returnThis then
- set activeObject to i
- set newrollover to 1
- set thisRollOver to 1
- sendmouseevents(me, xLoc)
- exit repeat
- end if
- end repeat
- else
- set returnThis to 0
- end if
- else
- set nextrollover to areYouThere(activeObject, thisMouseLoc)
- set newrollover to nextrollover <> thisRollOver
- set thisRollOver to nextrollover
- set returnThis to sendmouseevents(me, thisMouseLoc)
- end if
- return returnThis
- end
-
- on pointCursor me
- global savedcursor
- set savedcursor to #point
- end
-
- on grabCursor me
- global savedcursor
- set savedcursor to #grab
- end
-
- on plainCursor me
- global savedcursor
- set savedcursor to #plain
- end
-
- on blankCursor me
- global savedcursor
- set savedcursor to #blank
- end
-
- on sendmouseevents me, xPoint
- set sendmousedown to 0
- set sendmouseup to 0
- set sendmouseenter to 0
- set sendmouseleave to 0
- set sendmousemove to 0
- set sendmousedrag to 0
- set sendmousegone to 0
- if newrollover then
- if thisRollOver then
- set sendmouseenter to 1
- else
- set sendmouseleave to 1
- if not thisStillDown then
- set sendmousegone to 1
- end if
- end if
- end if
- if newstilldown then
- if thisRollOver then
- if thisStillDown then
- set sendmousedown to 1
- else
- set sendmouseup to 1
- end if
- else
- set sendmousegone to 1
- end if
- end if
- if newmouseloc then
- if thisStillDown then
- set sendmousedrag to 1
- else
- if thisRollOver then
- set sendmousemove to 1
- end if
- end if
- end if
- set thistime to the ticks
- if sendmousegone then
- set sendmousedrag to 0
- set sendmousemove to 0
- end if
- if sendmouseenter then
- set sendmouseup to 0
- mouseEvent(activeObject, #mouseEnter, thisMouseLoc)
- end if
- if sendmousedown then
- mouseEvent(activeObject, #mouseDown, thisMouseLoc)
- end if
- if sendmousedrag then
- mouseEvent(activeObject, #mouseDrag, thisMouseLoc)
- end if
- if sendmouseup then
- mouseEvent(activeObject, #mouseUp, thisMouseLoc)
- end if
- if sendmousemove then
- mouseEvent(activeObject, #mouseMove, thisMouseLoc)
- end if
- if sendmouseleave then
- mouseEvent(activeObject, #mouseLeave, thisMouseLoc)
- end if
- if sendmousegone then
- mouseEvent(activeObject, #mouseGone, thisMouseLoc)
- set activeObject to 0
- end if
- return thisRollOver
- end
-
- on resetcursor me
- global savedcursor
- case savedcursor of
- #point:
- pointCursor(me)
- #grab:
- grabCursor(me)
- #plain:
- plainCursor(me)
- #blank:
- blankCursor(me)
- end case
- end
-